package cn.wolfcode.luowowo2.mgrsite.web.controller;

import cn.wolfcode.luowowo2.mgrsite.util.UploadUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Albert on 2019/7/9.
 */
@Controller
@RequestMapping("uploadImg")
public class UploadController {
    @Value("${file.path}")
    private String realPath;

    @RequestMapping("")
    @ResponseBody
    public String uploadImg(MultipartFile pic){
        //String realPath = request.getServletContext().getRealPath("/upload");
        String fileName = UploadUtil.upload(pic, realPath);
        return fileName;
    }
}
